
#install.packages("diagram")
library(diagram)

par(mfrow=c(1,1))
par(mar=c(0,0,0,0))
##initialize new grphics device
openplotmat()
##number of elements per row
elpos<-coordinates (c(3, 3, 3, 3))
##draw arrows from each row to next row
straightarrow(from=elpos[4,],to=elpos[7,],lwd=1)  
straightarrow(from=elpos[7,],to=elpos[10,],lwd=1) 
straightarrow(from=elpos[6,],to=elpos[9,],lwd=1)  
straightarrow(from=elpos[9,],to=elpos[12,],lwd=1) 
fam <- "Times"
s <- 1.5
textplain(elpos[1,],lab="CDDC (n)", font = 2, adj = c(.5,3), cex = s, family=fam)
textplain(elpos[3,],lab="VTC (n)", font = 2, adj = c(.5,3), cex = s, family=fam)
textplain(elpos[2,],lab="Figure 1. Participant flow chart.", font = 2, cex = s, family=fam)

textplain(elpos[5,], lab="Screened", cex = s, family=fam)
textplain(elpos[8,], lab="Enrolled", cex = s, family=fam)
textplain(elpos[11,], lab="Analyzed", cex = s, family=fam)

x <- 0.15
y <- 0.1

textrect (elpos[4,],radx=x,rady=y,lab="168", shadow.size = 0, cex = s, family=fam)
textrect (elpos[6,],radx=x,rady=y,lab="113", shadow.size = 0, cex = s, family=fam)

textrect (elpos[7,],radx=x,rady=y,lab="98", shadow.size = 0, cex = s, family=fam)
textrect (elpos[9,],radx=x,rady=y,lab="98", shadow.size = 0, cex = s, family=fam)

textrect (elpos[10,],radx=x,rady=y,lab="89", shadow.size = 0, cex = s, family=fam)
textrect (elpos[12,],radx=x,rady=y,lab="95", shadow.size = 0, cex = s, family=fam)

